package com.example.servlet.servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @program: sms
 * @description:
 * @author: zhanghz001
 * @create: 2020-11-01 11:43
 **/
public class ServletDemo7 extends HttpServlet {
    @Override
    public void init() throws ServletException {
        System.out.println("init7");
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        String uri = req.getRequestURI();
        String path = uri.substring(uri.lastIndexOf("/"));
        if ("/servletDemo7".equals(path)) {
            System.out.println("servletDemo7为1号请求的业务");
        } else if ("/demo7".equals(path)) {
            System.out.println("servletDemo7为2号请求的业务");
        } else {
            System.out.println("servletDemo7");
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
